package com.zdkj.subway.st.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.st.entity.SwStProducePlanDetail;
import com.zdkj.subway.st.service.SwStProducePlanDetailService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@AllArgsConstructor
@RequestMapping("/swStProducePlanDetail")
@Api(value = "swStProducePlanDetail", tags = "车票生产计划分解明细")
public class SwStProducePlanDetailController {
	private final SwStProducePlanDetailService swStProducePlanDetailService;

	@GetMapping("/{id}")
	public R getById(@PathVariable String id) {
		return R.ok(swStProducePlanDetailService.getById(id));
	}

	@GetMapping("/page")
	public R<IPage> getDictPage(Page page, SwStProducePlanDetail swStProducePlanDetail) {
		return R.ok(swStProducePlanDetailService.page(page, Wrappers.query(swStProducePlanDetail)));
	}

	@SysLog("车票生产计划分解")
	@PostMapping
	public R save(@Valid @RequestBody SwStProducePlanDetail swStProducePlanDetail) {
		return R.ok(swStProducePlanDetailService.save(swStProducePlanDetail));
	}

	@SysLog("删除车票生产计划分解")
	@DeleteMapping("/{id}")
	public R removeById(@PathVariable String id) {
		return R.ok(swStProducePlanDetailService.removeById(id));
	}

	@PutMapping
	@SysLog("修改车票生产计划分解")
	public R updateById(@Valid @RequestBody SwStProducePlanDetail swStProducePlanDetail) {
		return R.ok(swStProducePlanDetailService.updateById(swStProducePlanDetail));
	}

}
